


package controller;




import bo.BUS_SanPham;
import com.opensymphony.xwork2.ActionSupport;
import dto.DTO_SanPham;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;





public class SanPhamAction extends ActionSupport implements ServletRequestAware {

    private ArrayList<DTO_SanPham> dssp;
    private HttpServletRequest request;
    private String tieude;
    public ArrayList<DTO_SanPham> getDssp() {
        return dssp;
    }

    public void setDssp(ArrayList<DTO_SanPham> dssp) {
        this.dssp = dssp;
    }

    public SanPhamAction() {

    }

    public String getTieude() {
        return tieude;
    }

    public void setTieude(String tieude) {
        this.tieude = tieude;
    }




    public String execute() throws Exception {

        if(request.getParameter("idLoai") != null)
        {
           int id = Integer.parseInt(request.getParameter("idLoai"));
           int gt = Integer.parseInt(request.getParameter("gt"));
           BUS_SanPham bus = new BUS_SanPham();
           dssp = bus.dsLoaiSanPham(id, gt);
           switch(id)
           {
               case 0:
                   tieude = "Áo thun";
                   break;
               case 1:
                   tieude = "Áo sơ mi";
                   break;
               case 2:
                   tieude = "Áo khoác";
                   break;
               case 3:
                   tieude = "Quần Jean";
                   break;
               case 4:
                   tieude = "Áo kaki";
                   break;
               case 5:
                   tieude = "Váy";
                   break;
           }
           switch(gt)
           {
               case 0:
                   tieude += " nữ";
                   break;
               case 1:
                   tieude +=" nam";
                   break;

           }
        }
        else
        {
            if(request.getParameter("idChude") != null)
            {
                int id = Integer.parseInt(request.getParameter("idChude"));
                BUS_SanPham bus = new BUS_SanPham();
                dssp = bus.dsChuDeSP(id);
                switch(id)
                {
                    case 0:
                        tieude = "Sản phẩm HOT";
                        break;
                    case 1:
                        tieude = "Sản phẩm mới";
                        break;
                    case 2:
                        tieude = "Sản phẩm khuyến mãi";
                        break;

                }
            }
        }

       return "success";

    }

    @Override
    public void setServletRequest(HttpServletRequest hsr) {
       request = hsr;
    }



}